package controller

import (
	"net/http"

	"github.com/gin-gonic/gin"
)

type Response struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
}

func Register(r *gin.Engine) {
	WorkflowRegister(r)
	ViewRegister(r)
	ProjectGroupRegister(r)
	NodesRegister(r)
	ProjectRegister(r)
}

func SendError(c *gin.Context, err error) {
	response := Response{Code: 50000, Message: err.Error()}
	c.JSON(http.StatusInternalServerError, response)
}

func SendData(c *gin.Context, data interface{}) {
	c.JSON(http.StatusOK, data)
}
